
package com.wssnail.xss.controller;

import com.wssnail.xss.model.User;
import com.wssnail.xss.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: yan
 * @CreateTime: 2023-07-28 16:47
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
public class UserController {


    @Autowired
    private UserService userService;

    @PostMapping("/save")
    public String save(@RequestBody User user) {
        userService.saveUser(user);
        return "success";
    }

    @GetMapping("/getById/{id}")
    public User getById(@PathVariable("id") Integer id) throws IllegalAccessException, NoSuchFieldException {
        return userService.getById(id);
    }

}
